package core;

public class Contact
{
    public String address;
    public int port;
    
    public Contact(String address, int port)
    {
        this.port = port;
        this.address = address;
    }
    
    @Override public boolean equals(Object that)
    {
        if (this == that) return true;
        if (!(that instanceof Contact)) return false;
        return hasEqualState((Contact)that);
    }
    
    private boolean hasEqualState(Contact that)
    {
        return ((this.address == null ? that.address == null : this.address.equals(that.address)) && (this.port == that.port));
    }
    
    @Override public int hashCode()
    {
        int hash = 0;
        hash = address.hashCode();
        hash += port;
        return hash;
    }
	
	@Override public String toString()
	{
		String res = new String();
		res = "";
		res += address;
		res += ":";
		res += port;
		return res;
	}
}